package edu.pe.cayetano.view.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.beanutils.RowSetDynaClass;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import ws.synopsis.frmwrk.common.BResult;
import edu.pe.cayetano.model.bo.NivelAcademicoBO;
import edu.pe.cayetano.seccd.constantes.ConstantesMensajes;
import edu.pe.cayetano.seccd.constantes.ConstantesSECCD;
import edu.pe.cayetano.util.EscribeLog;
import edu.pe.cayetano.util.UtilitarioSession;

public class NivelAcademicoAction extends BaseAction{
	
	private String 			page = ConstantesSECCD.EXITO;

	
	/**
	 * Metodo que lista los niveles academicos
	 * */
	public ActionForward listar(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
		BResult						ret			= new BResult();
		NivelAcademicoBO			nivelBO 	= new NivelAcademicoBO();
		try {
			HttpSession session = request.getSession(false);
			ret = nivelBO.listarNivelAcademico();
			if(ret.getCode()==0 && ret.getObject()!=null){
				page=ConstantesSECCD.EXITO;
				UtilitarioSession.eliminaParametrosBusquedaGenerico(session);
				UtilitarioSession.seteaParametrosListadoGenerico(session,(RowSetDynaClass)ret.getObject());
			}else{
				page=ConstantesSECCD.ERROR;
				EscribeLog.escribeLog("NivelAcademicoAction","listar",ConstantesSECCD.ERROR,ret.getMessage());
				mostrarMensaje(request,ConstantesMensajes.ERROR_NIVELACADEMICO_LISTAR,new String[0],"home.do","home");
			}
		}catch (Exception e) {
			page=ConstantesSECCD.ERROR;
			EscribeLog.escribeLog("NivelAcademicoAction","listar",ConstantesSECCD.ERROR,ret.getMessage());
			mostrarMensaje(request,ConstantesMensajes.ERROR_NIVELACADEMICO_LISTAR,new String[0],"home.do","home");
		}
		return mapping.findForward(page);	
	}
}
